<template>
  <!-- echart容器 -->
  <div class="charts" ref="charts" style="width:270px;height:60px"></div>
</template>

<script>
// 引入echarts
import * as echarts from 'echarts'

export default {
  name: 'lineCharts',
  mounted () {
    // 初始化
    let lineCharts = echarts.init(this.$refs.charts)
    lineCharts.setOption({
      xAxis: {
        // 隐藏坐标轴
        show: false,
        type: 'category'
      },
      yAxis: {
        show: false
      },
      grid: {
        top: 0,
        left: 0,
        right: 0,
        bottom: 0
      },
      series: [
        {
          type: 'line',
          data: [21, 16, 18, 20, 7, 13, 16, 11, 5, 11, 16, 22, 30],
          // 光滑度
          smooth: .6,
          // 拐点透明图
          itemStyle: {
            opacity: 0
          },
          // 线条样式
          lineStyle: {
            color: '#9172c9'
          },
          // 折线图填充样式
          areaStyle: {
            color: {
              type: 'linear',
              x: 0,
              y: 0,
              x2: 0,
              y2: 1,
              colorStops: [{
                offset: 0, color: '#9172c9' // 0% 处的颜色
              }, {
                offset: 1, color: '#fff' // 100% 处的颜色
              }],
              global: false // 缺省为 false
            }
          }
        }
      ]
    })
  }
}
</script>

<style>
</style>
